//
// Created by webturing on 2024/5/4.
//
#include<bits/stdc++.h>

using namespace std;

int jie() {
    int a, b;
    cin >> a >> b;
    if ( a == b ) return 0;
    if ( b > a ) {
        int s = b - a;
        if ( s % 2 ) {
            return 1;
        } else return 2;
    } else {
        int s = a - b;
        if ( s % 2 ) return 2;
        else return 1;
    }
}

int main() {
    int n;
    cin >> n;
    while (n--) {
        cout << jie() << endl;
    }
}